
#include	"SysConfig.h"
#include	"Define.h"


unsigned short UTILL_UTF8ToUnicode(unsigned char *ucData, unsigned char *ucBuf, unsigned char ucCnt, unsigned short usLimtCnt)
{
	unsigned short ucUTF8_Cnt = 0, ucUnicode_Cnt = 0;
	unsigned char  Tmp[3];
	unsigned char ucTemp;

	while(ucUTF8_Cnt < ucCnt)
	{
		ucTemp = ucData[ucUTF8_Cnt];
		if((ucTemp & 0x80) == 0) // 1char = 1Byte
		{
			ucBuf[ucUnicode_Cnt++] = ucData[ucUTF8_Cnt]; 				// low byte
			ucBuf[ucUnicode_Cnt++] = 0x00;								// high byte
			ucUTF8_Cnt++;
		}
		else if((ucTemp & 0xE0) == 0xC0) // 1char = 2Byte
		{
			Tmp[0] = ucData[ucUTF8_Cnt] & 0x1F;
			Tmp[1] = ucData[ucUTF8_Cnt +1] & 0x3F;
			ucBuf[ucUnicode_Cnt++] = (Tmp[0] << 6) | Tmp[1];			// low byte
			ucBuf[ucUnicode_Cnt++] = Tmp[0] >> 2;						// high byte
			ucUTF8_Cnt += 2;
		}
		else if((ucTemp & 0xF0) == 0xE0) // 1char = 3Byte
		{
			Tmp[0] = ucData[ucUTF8_Cnt] & 0x0F;
			Tmp[1] = ucData[ucUTF8_Cnt +1] & 0x3F;
			Tmp[2] = ucData[ucUTF8_Cnt +2] & 0x3F;
			ucBuf[ucUnicode_Cnt++] = (Tmp[1] << 6) | Tmp[2];			// low byte
			ucBuf[ucUnicode_Cnt++] = (Tmp[0] << 4) | (Tmp[1] >> 2);	// high byte
			ucUTF8_Cnt +=3;
		}
		else
		{
			ucUTF8_Cnt++;
		}
		if  ((usLimtCnt - ucUnicode_Cnt) < 2)
		{
			break;
		}
	}
	return ucUnicode_Cnt;
}

void UTILL_Delay(unsigned char ucCnt)
{
	unsigned char i;

	for(i = 0; i < ucCnt; ++i)
	{
	
	}
}

